<?php

declare (strict_types=1);

namespace app\bbxw\controller;


use think\admin\Controller;
use think\admin\helper\QueryHelper;
use app\bbxw\model\MembershipCard as MembershipCardMod;

/**
 * 会员等级配置
 * @class Package
 * @package app\bbxw\controller
 */
class MembershipCard extends Controller
{

    /**
     * 绑定数据表
     * @var string
     */
    private $table = 'membership_card';
    /**
     * 会员等级配置
     * @auth true
     * @menu true
     * @login true
     */
    public function index()
    {

        MembershipCardMod::mQuery()->layTable(function () {
            $this->title = '会员等级管理';
        }, function (QueryHelper $query) {
            $query->like('title')->order('id asc');
        });

    }

    /**
     * 会员等级列表数据处理
     * @param array $data
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    protected function _page_filter(array &$data)
    {

    }


    /**
     * 添加会员等级
     * @auth true
     */
    public function add()
    {
        $this->title = '添加会员等级';
        MembershipCardMod::mForm('form');
    }

    /**
     * 表单数据处理
     * @param array $data
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    protected function _form_filter(array &$data)
    {

    }
    /**
     * 编辑会员等级
     * @auth true
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function edit()
    {
        $this->title = '编辑会员等级';
        MembershipCardMod::mForm('form');
    }


    /**
     * 删除会员等级
     * auth true
     */
    public function remove()
    {
        MembershipCardMod::mDelete();
    }
}